package app.web.cartoon.report.size.tab;

import app.web.cartoon.report.size.tool.CartoonSizeReport;
import cn.lily.com.exception.YaconException;
import cn.lily.web.page.BusinessPage;
import cn.lily.web.widget.sql.TSqlGrid;
import cn.lily.web.widget.standard.TButton;
import cn.lily.web.widget.standard.TButtonPilot;
/**
 * 动漫基本体积统计
 * @author JiaJ
 *
 */
public class SizeReport extends BusinessPage {

	@Override
	public void page_onLoad() throws YaconException {
		
		 TSqlGrid sizeGrid = sqlGrid("sizeGrid");
		 sizeGrid.setDictTable("LEO_CAN_REPORT_SIZE");
		 String sqlString = " select to_char(RES_TIME,'yyyy-mm-dd hh24:mi:ss') RES_TIME,LEO_CAN_DATE_INF,LEO_CAN_SIZE_TOTAL,LEO_CAN_SIZE_TOTAL_EXP,LEO_CAN_SIZE_SIZE,LEO_CAN_SIZE_SIZE_EXP "
		 				  + " from ${schema}.LEO_CAN_REPORT_SIZE "
		 				  + " order by RES_TIME DESC ";
		 sizeGrid.setCommSqlStr(sqlString);
		 sizeGrid.setEdit(true);

	     sizeGrid.createFieldTitle("RES_TIME").setFieldVisible(false);
		 sizeGrid.createFieldTitle("LEO_CAN_DATE_INF");
		 sizeGrid.createFieldTitle("LEO_CAN_SIZE_TOTAL");
		 sizeGrid.createFieldTitle("LEO_CAN_SIZE_TOTAL_EXP").setFieldVisible(false);
		 sizeGrid.createFieldTitle("LEO_CAN_SIZE_SIZE");
		 sizeGrid.createFieldTitle("LEO_CAN_SIZE_SIZE_EXP").setFieldVisible(false);
		 
		 TButtonPilot singleTablePilot = ButtonPilot("sizeGridPilot");
		 singleTablePilot.setPilotIco("/widget/buttonPilot.gif");
		 singleTablePilot.setPilotText("动漫体积统计");

		 TButton sizeReport = new TButton("sizeReportBtn");
		 sizeReport.setIcoPath("glyphicon glyphicon-th-large");
		 sizeReport.setLabel("动漫体积统计");
		 sizeReport.setViewClick("sizeBtn_onclick");
		 singleTablePilot.addButtons(sizeReport);

		 sizeGrid.setButtonPilot(singleTablePilot);
		 
		 sizeGrid.setTopButtonType("all");
		 
		 getPage().addElement(sizeGrid);

		
	}
	
	public void refresh(){
		 TSqlGrid sizeGrid = sqlGrid("sizeGrid");
		 String sqlString = " select to_char(RES_TIME,'yyyy-mm-dd hh24:mi:ss') RES_TIME,LEO_CAN_DATE_INF,LEO_CAN_SIZE_TOTAL,LEO_CAN_SIZE_TOTAL_EXP,LEO_CAN_SIZE_SIZE,LEO_CAN_SIZE_SIZE_EXP "
		 				  + " from ${schema}.LEO_CAN_REPORT_SIZE "
		 				  + " order by RES_TIME DESC";
		 sizeGrid.setCommSqlStr(sqlString);
		 this.setSelfMessage(sizeGrid.getDataElement());
	}
	
	public void numSize(){
		
		try {
			
			CartoonSizeReport sizeReport = new CartoonSizeReport();		
			sizeReport.inst();
			
		} catch (Exception e) {
			e.printStackTrace();
			this.setSelfMessage("动漫体积统计失败！");
		}
		
		this.setSelfMessage("动漫体积统计成功！");
	}
	

}
